package com.study.jvm;

import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;

class NewDemo {
    private String age;
    private String age1;
    private static NewDemo demo;
    private boolean run;
    private short tet;
    private short tr;
    private boolean tr1;
    private Boolean tr2;
}

public class NewObjectSize {
    //分代年龄可以通过如下参数调整
    //-XX:MaxTenuringThreshold=16  MaxTenuringThreshold of 16 is invalid; must be between 0 and 15
    //-XX:+UseCompressedClassPointers 开启指针压缩
    public static void main(String[] args) throws InterruptedException {
        System.out.println(VM.current().details());
        NewDemo o = new NewDemo();
        System.gc();


        System.out.println("o = " + ClassLayout.parseInstance(o).toPrintable(o));
        NewDemo[] o1 = new NewDemo[(int) Math.pow(2, 15)];
        System.out.println("o = " + ClassLayout.parseInstance(o1).toPrintable());
        System.out.println("o = " + ClassLayout.parseInstance("").toPrintable());
    }
}
